package org.zcl.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.zcl.feign.UserServiceFeignClient;
import org.zcl.feign.UserServiceFeignClient2;

/**
 * .
 *
 * @Author Chenglin Zhu
 * @Date 2022/1/23 7:45 下午
 */
@RestController
@RequestMapping("/feign-demo")
@Slf4j
@Api(value = "FeignDemoController", tags = "FeignDemoController")
public class FeignDemoController {


    @Autowired
    private UserServiceFeignClient userServiceFeignClient;

    @Autowired
    private UserServiceFeignClient2 userServiceFeignClient2;

    @GetMapping("/get_user")
    @ApiOperation(value = "getUser", notes = "getUser")
    public String getUser(@RequestParam("id") Integer id) {
        log.info("[getUser][准备调用 user-service 获取用户({})详情]", id);
        return userServiceFeignClient.getUser(id);
    }

    @GetMapping("/hi")
    @ApiOperation(value = "hi", notes = "hi")
    public String hi(@RequestParam("name") String name) {
        log.info("[hi][准备调用 user-service 获取用户({})详情]", name);
        return userServiceFeignClient2.sayHi(name);
    }

}